IF EXISTS (SELECT * FROM sysobjects where name = 'Ticket' and xtype ='U')
	BEGIN
		PRINT 'La Tabla "dbo.Ticket" ya existe.';
	END
ELSE
	BEGIN
		CREATE TABLE dbo.Ticket		
		(	
			Id				int IDENTITY(1, 1) NOT NULL,
			Nombre			nvarchar(50) NOT NULL,
			Descripcion		nvarchar(150) NOT NULL,
			FechaInicio		datetime NOT NULL,
			FechaFin		datetime NULL,
			IdSala			int NULL,			
			CONSTRAINT PK_TICKET PRIMARY KEY(Id),
			CONSTRAINT FK_TICKET_SALA FOREIGN KEY(IdSala) REFERENCES Sala(Id),
			CONSTRAINT UQ_TICKET UNIQUE (Nombre)
		);
		PRINT 'La tabla "dbo.Ticket" se ha creado correctamente.';
	END
GO